import { fileURLToPath, URL } from "node:url";

import { defineConfig } from 'vite'
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import {AntDesignVueResolver} from "unplugin-vue-components/resolvers"
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: true,
    port: 10003,
    proxy: {
      "/api": {
        target: "http://localhost:20001",
        // target: "http://192.168.31.69:20001",
        changeOrigin: false,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
  plugins: [
      vue(),
      AutoImport({
        imports: [
          "vue",
          "vue-router",
        ],
        dirs: ["src/composables"],
        dts: "src/auto-imports.d.ts",
        // resolvers: [AntDesignVueResolver()]
      }),
      Components({
        resolvers: [AntDesignVueResolver({importStyle: false, resolveIcons: true})],
        dirs: ["**/components"],
        dts: "src/components.d.ts",
      }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
})
